package org.bonorsoft.modules.education.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.bonorsoft.modules.education.entity.Enclosure;
import org.bonorsoft.modules.education.mapper.EnclosureMapper;
import org.bonorsoft.modules.education.service.IEnclosureService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @Description: 附件表
 * @Author: WilliamYe
 * @Date:   2021-06-22
 * @Version: V1.0
 */
@Service
public class EnclosureServiceImpl extends ServiceImpl<EnclosureMapper, Enclosure> implements IEnclosureService {


    @Override
    public boolean add(String noticeResponseId, String fileName, String file) {
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        return this.baseMapper.add(uuid, noticeResponseId, fileName, file);
    }

    @Override
    public String getFileByNoticeId(String noticeResponseId) {
        return this.baseMapper.getFileByNoticeId(noticeResponseId);
    }

    @Override
    public int countByNoticeId(String noticeResponseId) {
        return this.baseMapper.countByNoticeId(noticeResponseId);
    }

    @Override
    public boolean save(String noticeResponseId, String file) {
        return this.baseMapper.save(noticeResponseId, file);
    }

    @Override
    public int deleteByNoticeId(String noticeResponseId) {
        return this.baseMapper.deleteByNoticeId(noticeResponseId);
    }

    @Override
    public void deleteByNoticeIds(List<String> noticeResponseIds) {
        for (String noticeResponseId : noticeResponseIds) {
            this.baseMapper.deleteByNoticeId(noticeResponseId);
        }
    }

}
